<%-- 
    Document   : validarusu
    Created on : 02/06/2014, 17:27:21
    Author     : Taynah
--%>

<%@page import="java.sql.SQLException"%>
<%@page import="java.sql.DriverManager"%>
<%@page import="java.sql.ResultSet"%>
<%@page import="java.sql.Statement"%>
<%@page import="java.sql.Connection"%>
<%@page import="br.com.fatecpg.jdbc.web.OracleConnector"%>
<%@page contentType="text/html" pageEncoding="UTF-8"%>
<!DOCTYPE html>
<html>
    <head>
        <meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
        <title>JSP Page</title>
    </head>
    <body>
         <% 
             String usuario=request.getParameter("txt_login");
             String senha=request.getParameter("senha");
             Connection con=null;
             Statement stmt=null;
             ResultSet rs=null;
             try{
                 Class.forName("oracle.jdbc.driver.OracleDriver");
                 con=DriverManager.getConnection("jdbc:oracle:thin:@localhost:1521:XE","hr","hr");
                 stmt=con.createStatement();
                 rs=stmt.executeQuery("SELECT * FROM cliente WHERE cd_cpf_cliente='"+usuario+"' AND cd_senha='"+senha+"'");
                 if(rs.next()==true){
                     session.setAttribute("txt_login", request.getParameter(rs.getString("nm_cliente")));
                     session.setAttribute("cpf",usuario);
                     %> <a href="Inicio.jsp"> Entrar </a><%
                 }else{
                     out.println("<span style='color:red;'>Usuário e/ou senha inválido(s)! </span>");
                     %> <a href="Login.jsp"> Voltar </a><%
                 }
             }catch(Exception e){
                 out.println("ERRO");
             }finally{
                 rs.close();
                 stmt.close();
             }
             
             
               %>
    </body>
</html>
